package com.jgk.guice.basic.gettingstarted;

//import javax.inject.Inject;

import com.google.inject.Inject;
import com.google.inject.name.Named;



public class RealBillingService implements BillingService {
    private final CreditCardProcessor processor;
    private final TransactionLog transactionLog;
    private String apiKey;
    private String someOptionalKey = "I AM DEFAULT KEY";
    private String lastName;
    private BogusSpringBeanHere bogusSpringBeanHere;
    
    @Inject
    RealBillingService(@Named("funkyBogusSpringBeanHere") BogusSpringBeanHere bsb,  CreditCardProcessor processor, 
        TransactionLog transactionLog) {
        System.out.println("CREATING RealBillingService");
      this.processor = processor;
      this.transactionLog = transactionLog;
      this.bogusSpringBeanHere = bsb;
    }
    public Receipt chargeOrder(PizzaOrder order, CreditCard creditCard) {
        return new Receipt();
    }
    @Inject
    public void setLastName(@Named("last name") String lastName) {
        System.out.println("lastName:" +lastName);
        this.lastName = lastName;
    }
    @Inject
    public void setApiKey(@Named("FREAKY API key") String apiKey) {
        System.out.println("apiKey:" +apiKey);
        this.apiKey = apiKey;
    }
    @Inject(optional=true)
    public void setSomeOptionalKey(String someOptionalKey) {
        System.out.println("someOptionalKey:  " + this.someOptionalKey);
        this.someOptionalKey = someOptionalKey;
        System.out.println("LATER: someOptionalKey: " + this.someOptionalKey);
    }
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("RealBillingService [processor=");
        builder.append(processor);
        builder.append(", transactionLog=");
        builder.append(transactionLog);
        builder.append(", apiKey=");
        builder.append(apiKey);
        builder.append(", someOptionalKey=");
        builder.append(someOptionalKey);
        builder.append(", lastName=");
        builder.append(lastName);
        builder.append(", bogusSpringBeanHere=");
        builder.append(bogusSpringBeanHere);
        builder.append("]");
        return builder.toString();
    }
    
    
}
